package Week3.J0504;

public class 零一背包_xx {
    int[] dp = new int[1010];
    public int knapsack (int V, int n, int[][] vw) {
        for (int i = 0; i < n; i++) {
            for (int j = V; j >= vw[i][0]; j--) {
                dp[j] = Math.max(dp[j], dp[j-vw[i][0]] + vw[i][1]);
            }
        }
        return dp[V];
    }
}
